Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Adding a toggle box to the window
There are no
LOGICALfields in the Customer and Order tables to display as toggle boxes, but you can add a variable to display as a toggle box instead.
![]()
To add a toggle box that lets the user change whether the fields with warehouse information are displayed at run time:
- Select the Toggle Box icon from the Palette:
![]()
- Click in the design window to the right of the Total Ext price field to drop the toggle box onto the window.
- Change the Object name to lShowWarehouse (starting with the letter l because it’s a representation of a
LOGICALvariable) and change the Label to Show Warehouse Info.- Adjust the size of the toggle box to show the whole label.
- Go into the property sheet for the toggle box, click the Advanced button, and change its initial value from no to yes.
- Select the Edit Code icon and define this
VALUE-CHANGEDtrigger for the field:
Remember that a field value entered on the screen does not get saved to the record buffer until it is assigned. Therefore, the trigger block has to start with an
ASSIGNstatement for the variable before you can refer to its value. Alternatively, you could query theSCREEN-VALUEattribute of the field without assigning it. When you reference theSCREEN-VALUE, however, the value is represented as a character string, even though it’s not displayed that way, so you would have to explicitly compare theSCREEN-VALUEtoYESorNOlike this:
By contrast, when you assign the value to its record buffer, you can refer to it as a
LOGICALso that it becomes in effect a one-field expression that evaluates to true or false:
Your new trigger is setting the
HIDDENattribute of the two warehouse-related fields to true or false. When you run the procedure and click the toggle box, the fields appear and disappear:
![]()
Looking at the code to define a toggle box
This is the
DEFINE VARIABLEstatement the AppBuilder generated to define this toggle box (you can see this code from the Code Preview window):
The
INITIALvalue,LABEL,VIEW-AStype, andSIZEare all defined here. As with other fields, the toggle box is enabled not by syntax in theDEFINE VARIABLEstatement, but because it’s added to theENABLEstatement inenable_UI.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |